[#include "../../../common/html.ftl" /]
[@html]
    [@head title="登录日志列表" css=["fw", "bootstrap-table"] /]
    [@body]
        [#--主体内容--]
        [@main ]
            <div class="am-g am-radius fw-tables">
                [#--表格主体内容--操作栏--]
                [@mainHeader]
                    <button class="am-btn am-btn-danger am-radius" onclick="$.operate.clean()">清空</button>
                    [#--[@shiro.hasPermission name="monitor:logininfor:unlock"]--]
                    <button class="am-btn am-btn-primary am-radius multiple am-disabled" onclick="unlock()">解锁</button>
                    [#--[/@shiro.hasPermission]--]
                [/@mainHeader]

                [#--表格主体内容--搜索栏--]
                [@searchForm searchId="form-logininfor-search" ]
                    <div class="am-form-group">
                        <input type="text" name="loginName" class="am-form-field am-input-sm am-radius" placeholder="登录账号">
                    </div>
                    <div class="am-form-group">
                        <input type="text" name="userName" class="am-form-field am-input-sm am-radius" placeholder="用户姓名">
                    </div>
                    <div class="am-form-group">
                        <input type="text" name="ipaddr" class="am-form-field am-input-sm am-radius" placeholder="登录地址">
                    </div>
                    <div class="am-form-group">
                        <select name="configType" class="am-radius" data-am-selected placeholder="登录状态">
                            <option value=""></option>
                            [#list dict.getType("sys_oper_status") as dict]
                                <option value="${dict.dictValue}">${dict.dictLabel}</option>
                            [/#list]
                        </select>
                    </div>
                    <div class="am-form-group">
                        <div class="am-form-group am-form-icon">
                            <i class="am-icon-calendar"></i>
                            <input type="text" name="params[beginTime]" class="am-form-field am-input-sm am-radius" placeholder="登录时间-开始"
                                   data-am-datepicker readonly/>
                        </div>
                        <div class="am-form-group am-form-icon">
                            <i class="am-icon-calendar"></i>
                            <input type="text" name="params[endTime]" class="am-form-field am-input-sm am-radius" placeholder="登录时间-结束"
                                   data-am-datepicker readonly/>
                        </div>
                    </div>
                [/@searchForm]

                <div class="fw-table">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        [/@main]

        [#--PC/APP 右侧悬浮按钮--]
        [@rightToolbar /]

        [@script js=["fw", "bootstrap-table"]]
            <script type="text/javascript">
                var datas = ${convert.toJson(dict.getType("sys_oper_status"))};
                var prefix = ctx + "osfw/system/monitor/logininfor";

                $(function () {
                    var options = {
                        url: prefix + "/list",
                        cleanUrl: prefix + "/clean",
                        removeUrl: prefix + "/remove",
                        exportUrl: prefix + "/export",
                        modalName: "登录日志",
                        escape: true,
                        showPageGo: true,
                        rememberSelected: true,
                        uniqueId: "infoId",
                        columns: [{
                            field: 'state',
                            checkbox: true
                        },
                            {
                                title: "序号",
                                formatter: function (value, row, index) {
                                    return $.table.serialNumber(index);
                                }
                            },
                            {
                                field: 'loginName',
                                title: '登录账号',
                                sortable: true,
                                formatter: function (value, row, index) {
                                    return $.table.tooltip(value, 15);
                                }
                            },
                            {
                                field: 'userName',
                                title: '用户姓名',
                                sortable: true,
                                formatter: function (value, row, index) {
                                    return $.table.tooltip(value, 15);
                                }
                            },
                            {
                                field: 'ipaddr',
                                title: '登录地址'
                            },
                            {
                                field: 'loginLocation',
                                title: '登录地点',
                                visible: false,
                            },
                            {
                                field: 'browser',
                                title: '浏览器'
                            },
                            {
                                field: 'os',
                                title: '操作系统',
                                visible: false
                            },
                            {
                                field: 'status',
                                title: '登录状态',
                                align: 'left',
                                formatter: function (value, row, index) {
                                    return $.table.selectDictLabel(datas, value);
                                }
                            },
                            {
                                field: 'msg',
                                title: '操作信息',
                                visible: false,
                            },
                            {
                                field: 'loginTime',
                                title: '登录时间',
                                sortable: true
                            }]
                    };
                    $.table.init(options);
                });

                function unlock() {
                    $.operate.post(prefix + "/unlock?loginName=" + $.table.selectColumns("loginName"));
                }

            </script>
        [/@script]
    [/@body]
[/@html]
